
package command;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Antonin Mozzati
 * @author Yannick Schürter
 */
public class CommandManager {

    protected static ConcurrentHashMap<String, Command> cmds = new ConcurrentHashMap<String, Command>();

    static {
        init();
    }

    public static void init() {
        cmds.put("login", new ConnectCommand());
        cmds.put("deconnexion", new DeconnectCommand());
        cmds.put("subscribe", new SubscribeCommand());
        cmds.put("perso", new PersoCommand());
        cmds.put("editerProfil", new ProfilCommand());
        cmds.put("addFlux", new AddFluxCommand());
        cmds.put("rechercherUtilisateur", new RechercherUtilisateurCommand());
        cmds.put("afficherFluxPublic", new AfficherFluxPublicCommand());
        cmds.put("abonnements", new AbonnementsCommand());
        cmds.put("invitations", new InvitationsCommand());
        cmds.put("supprimerNouvelle", new SupprimerNouvelleCommand());
        cmds.put("inviter", new InviterCommand());
        cmds.put("rechercherNouvelle", new RechercherNouvelleCommand());

    }

    public static Command getCommand(String commandName) {
        return cmds.get(commandName);
    }
}

//import java.lang.reflect.*;
//
//Class [] classParm = null;
//Object [] objectParm = null;
//
//try {
//  String name = "com.rgagnon.MyClass";
//  Class cl = Class.forName(name);
//  java.lang.reflect.Constructor co = cl.getConstructor(classParm);
//  return co.newInstance(objectParm);
//  }
//catch (Exception e) {
//  e.printStackTrace();
//  return null;
//}